faApp.controller('salesPrizesListCtrl',['$scope','salesPrizesService','$location','$controller','$routeParams','$filter','$route',function($scope,salesPrizesService,$location,$controller,$routeParams,$filter,$route) {   
  $controller('BaseListCtrl', {$scope: $scope}); 

  $scope.item={salesPrizes:""};

  $scope.iteminfo={};

  $scope.submitAdd = function(){
    if(!$scope.item.salesPrizes){
      alert("请填写好内容!!");
      return ;
    }
    if(confirm("请确认更新所有奖项?")){
      try{
        var a = $scope.item.salesPrizes.split('\n');
        console.log(a);
        if(a[0].split(",").length>=2){
          console.log(a);
        }else{
          alert("格式不正确!!");
          return ;
        }
      }catch(e){
        console.log(e);
        alert("格式不能解析!!");
        return ;
      }
      
      salesPrizesService.salesPrizesAdd($scope.item).then(function(json){
      if (json.statusCode){
        alert("出错了:" + json.statusCode);
      }else{
        alert("新增成功");
        $route.reload();
      }
    });
    }else{
      alert("填写内容");
    }
    
  }

  salesPrizesService.salesPrizesList($scope.config).then(function(json){
      if (json.statusCode){
        alert("出错了:" + json.statusCode);
      }else{
        $scope.iteminfo=json.list;
        $scope.pager = json.pager;
      }
    });


}]);

faApp.controller('salesPrizesPeopleListCtrl',['$scope','salesPrizesService','$location','$controller','$routeParams','$filter','$route',function($scope,salesPrizesService,$location,$controller,$routeParams,$filter,$route) {   
  $controller('BaseListCtrl', {$scope: $scope}); 

  $scope.item={salesPrizesPeople:""};

  $scope.submitAdd = function(){
    if(!$scope.item.salesPrizesPeople){
      alert("请填写好内容!!");
      return ;
    }
    if(confirm("请确认更新所有人员?")){
      try{
        var a = $scope.item.salesPrizesPeople.split('\n');
        console.log(a);
        if(a[0].split(",").length>=2){
          console.log(a);
        }else{
          alert("格式不正确!!");
          return ;
        }
      }catch(e){
        console.log(e);
        alert("格式不能解析!!");
        return ;
      }
      
      salesPrizesService.salesPrizesPeopleAdd($scope.item).then(function(json){
      if (json.statusCode){
        if(json.statusCode=='4021'){
          alert("存在名单重复,"+json.phone);
        }else{
          alert("出错了:" + json.statusCode);
        }
        
      }else{
        alert("新增成功");
        $route.reload();
      }
    });
    }else{
      alert("填写内容");
    }
    
  }

  salesPrizesService.salesPrizesPeopleList($scope.config).then(function(json){
      if (json.statusCode){
        alert("出错了:" + json.statusCode);
      }else{
        $scope.iteminfo=json.list;
        $scope.pager = json.pager;
      }
    });
}]);